﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace CloudDcPc
{
    /// <summary>
    /// PrintTest.xaml 的交互逻辑
    /// </summary>
    public partial class PrintTest : Window
    {
        private IPEndPoint ServerInfo;
        private Socket ClientSocket;
        //信息接收缓存
        private Byte[] MsgBuffer;
        //信息发送存储
        private Byte[] MsgSend;
        public PrintTest()
        {
            InitializeComponent();
            ClientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            MsgBuffer = new Byte[65535];
            MsgSend = new Byte[65535];
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            ServerInfo = new IPEndPoint(IPAddress.Parse("192.168.1.222"), Convert.ToInt32("9100"));
            ClientSocket.Connect(ServerInfo);
            string str = "dfdsf\n\n中文啊\n\n中文啊\n\n\n中文啊\n";
            byte[] b = System.Text.Encoding.GetEncoding("GB2312").GetBytes(str);
            //ClientSocket.Send(Encoding.Unicode.GetBytes(str));
            ClientSocket.Send(b);
            byte[] logout = new byte[4] { 0x1d, 0x56, 0x00, 0x48 };
            ClientSocket.Send(logout);
            ClientSocket.Shutdown(SocketShutdown.Both);
            ClientSocket.Close();
        }
    }
}
